package com.carlos.gateway.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.carlos.gateway.mapper.SysUserRoleMapper;
import com.carlos.gateway.pojo.SysUserRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 李健成
 * @date 2021/10/15
 */

@Service
public class SysUserRoleService extends ServiceImpl<SysUserRoleMapper, SysUserRole> {

    @Autowired
    private SysUserRoleMapper sysUserRoleMapper;

    private List<SysUserRole> listAllByUsername(String username) {
        return sysUserRoleMapper.listAllByUsername(username);
    }

    public List<String> listRoleCodeByUsername(String username) {
        return this.listAllByUsername(username).stream()
                .map(SysUserRole::getRoleCode)
                .collect(Collectors.toList());
    }

}
